#!/usr/bin/env bash
#dev-install.sh

sudo yum clean all
sudo yum update -y

sudo yum install -y wget unzip openssl curl

#TODO how to get mariadb on different linux version
#name_=$(cat /etc/*-release | grep ^ID= | cut -d"=" -f2)
#version_=$(cat /etc/*-release | grep ^VERSION_ID= | cut -d"=" -f2)
#release_=$name_$version_
echo "installing mariadb 10.1 ..."
sudo echo "# MariaDB 10.1 CentOS repository list - created 2016-09-10 01:33 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1" >> /etc/yum.repos.d/MariaDB.repo

sudo yum install -y MariaDB-server MariaDB-client
#yum install -y mysql-server mysql-client

echo "as you know, there is firefox in the system, so let's begin installing chrome ..."
if [ "$(uname -m)" = "x86_64" ]; then
    wget -c https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
    sudo rpm -i google-chrome-stable_current_x86_64.rpm
else
    #TODO chang it to i386
    wget -c https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
    sudo rpm -i google-chrome-stable_current_x86_64.rpm
fi

echo "vscode and atom is my style，O(∩_∩)O"
wget -c https://az764295.vo.msecnd.net/stable/07d663dc1bd848161edf4cd4ce30cce410d3d877/code-1.5.1-1473370243.el7.x86_64.rpm
sudo rpm -i code-1.5.1-1473370243.el7.x86_64.rpm
#wget -c https://github-cloud.s3.amazonaws.com/releases/3228505/4d8e003e-7506-11e6-8c1b-69e64d1becbe.rpm?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20160910%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20160910T075002Z&X-Amz-Expires=300&X-Amz-Signature=f01691687108b52df2f5de610753971adab5f0bfdff16c35d2b8d1457f33e56e&X-Amz-SignedHeaders=host&actor_id=14797057&response-content-disposition=attachment%3B%20filename%3Datom.x86_64.rpm&response-content-type=application%2Foctet-stream
#rpm -i atom.x86_64.rpm
#something wrong

echo "git svn which is yours? download all ..."
sudo yum install git subversion -y

echo "let's begin install docker ..."
sudo sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

sudo yum clean all && makecache
sudo yum install docker-engine

echo "how about something fun?"
sudo yum install gimp inkscape dia zhcon blender
#网易云音乐 (●'◡'●) 有问题，安装不了
#wget -c http://122.228.233.142/dl-cdn.senorsen.com/linux/rpm/netease-cloud-music-1.0.0-1.x86_64.rpm
#sudo rpm -i netease-cloud-music-1.0.0-1.x86_64.rpm